@import '../../styles/var.less';

.k-menu,
.k-dropdown-menu {
  display: block;
  margin: 0;
  padding: 0;
  outline: 0;
  font-size: 14px;
  position: relative;
  zoom: 1;
  background: var(--kui-color-back);
  list-style: none;
  color: var(--kui-color-font);
  // transition: background-color .3s cubic-bezier(.645, .045, .355, 1), width .3s cubic-bezier(.645, .045, .355, 1);
  transition: width .3s cubic-bezier(.645, .045, .355, 1);
  user-select: none;
  box-sizing: border-box;

  // &:after, &:before {
  //   content: "";
  //   display: table;
  // }
  &-item-divider {
    height: 1px;
    margin: 4px 0;
    overflow: hidden;
    line-height: 0;
    background-color: var(--kui-color-border);
  }

  // .k-menu-icon-temp {
  //   display: inline-block;
  //   width: 20px;
  //   height: 20px;
  //   margin-right: 8px;
  //   flex-shrink: 0;
  // }

  .k-menu-title-content {
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 1;
    white-space: nowrap;
    transition: all .3s ease-in-out;
    line-height: 1.571;
  }

  .k-menu-item-icon {
    margin-right: 8px;
    font-size: 14px;
    transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);

  }


  &-submenu-arrow {
    transition: all .3s;
    // position: absolute;
    // right: 16px;
    margin-left: 6px;
    width: 14px;
    // height: 14px;
    text-indent: 0;
  }

  .k-menu-submenu {
    margin: 0;
  }

  &-item,
  .k-menu-submenu-title,
  .k-dropdown-menu-item,
  .k-dropdown-menu-submenu-title {
    padding: 10px 12px;
    box-sizing: border-box;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    position: relative;
    // transition: font-size .3s cubic-bezier(.215, .61, .355, 1), padding .3s cubic-bezier(.215, .61, .355, 1);
    // transition: all .3s cubic-bezier(.215, .61, .355, 1);
    transition: border .3s ease-in-out;
    list-style: none;
    height: 40px;
    display: flex;
    align-items: center;
  }

  .k-dropdown-menu-item {
    height: 32px;
  }

  .k-dropdown-menu-submenu-title,
  .k-menu-submenu-title {
    .k-menu-title-content {
      width: calc(100% - 20px);
    }
  }

  //light
  .k-menu-item-group-title {
    font-size: 12px;
    color: var(--kui-color-icon);
  }

  a {
    color: var(--kui-color-font);
    text-decoration: none;

    &:hover {
      text-decoration: none;
    }
  }

  .k-menu-item-active {
    // color: var(--kui-color-main);
    background-color: var(--kui-color-hover);
  }

  .k-menu-item-selected {
    color: var(--kui-color-main);
    background-color: var(--kui-color-selected);

    a {
      color: var(--kui-color-main);
    }
  }

  >.k-menu-submenu-selected {

    // >.k-menu-submenu-active {
    >.k-menu-submenu-title {
      color: var(--kui-color-main);
    }
  }

  .k-menu-item-disabled,
  .k-menu-submenu-disabled {
    * {
      color: var(--kui-color-disable-color);
      cursor: not-allowed;
    }
  }
}

.k-dropdown-menu {
  box-shadow: 0 1px 6px rgba(0, 0, 0, .2);
  border-radius: var(--kui-border-radius);
  display: inline-block;

  .k-dropdown-menu-item,
  .k-dropdown-menu-submenu-title {
    margin: 4px;
    padding: 10px 12px;
    box-sizing: border-box;
    border-radius: var(--kui-border-radius);
    height: 32px;

    &:hover {
      background-color: var(--kui-color-hover);
    }

    &:active {
      background-color: var(--kui-color-active);
    }
  }

  .k-dropdown-menu-item-disabled,
  .k-dropdown-menu-submenu-disabled {
    * {
      color: var(--kui-color-disable-color);
      cursor: not-allowed;
    }
  }
}

.k-menu {

  //light-end
  &-inline {
    border-right: 1px solid var(--kui-color-border);
    width: 100%;
    display: inline-block;

    .k-menu-item,
    .k-menu-submenu {
      line-height: 1;
      font-size: 14px;
      list-style: none;
    }

    .k-menu-item-group-title {
      padding: 0 16px 0 32px;
      box-sizing: border-box;
    }

    .k-menu {
      border: 0;
      list-style: none;
      margin: 0;
      padding: 0;
    }

    .k-menu-item {
      padding: 10px 12px;
      // width: calc(100% + 1px);
      // width:100%;
      box-sizing: border-box;
      position: relative;
      margin: 4px;
      border-radius: var(--kui-border-radius);
      display: flex;
      align-items: center;
      height: 40px;

      &::after {
        content: '';
        position: absolute;
        width: 0;
        height: 0;
        border-right: 3px solid var(--kui-color-main);
        top: 50%;
        right: 0;
        transition: all .3s cubic-bezier(.215, .61, .355, 1);
      }

      &:active {
        background: var(--kui-color-active);
      }
    }

    .k-menu-submenu-active .k-menu-submenu-title:active {
      background: var(--kui-color-active);
    }

    .k-menu-submenu {
      .k-menu-item {

        // padding: 10px 24px 10px 12px;
        &:first-child {
          margin-top: 0;
        }
      }
    }

    .k-menu-submenu-title {
      padding: 10px 36px 10px 12px;
      box-sizing: border-box;
      position: relative;
      margin: 0 4px 4px 4px;
      border-radius: var(--kui-border-radius);

      .k-menu-submenu-arrow {
        position: absolute;
        right: 16px;
        top: 50%;
        transform: translateY(-50%);

        &::after,
        &::before {
          content: '';
          position: absolute;
          width: 6px;
          height: 1.5px;
          background-color: currentcolor;
          border-radius: 6px;
          transition: all .3s cubic-bezier(.215, .61, .355, 1);
        }

        &::before {
          transform: rotate(45deg) translateX(-2.5px);
        }

        &::after {
          transform: rotate(-45deg) translateX(2.5px);
        }
      }

      &:hover {
        background-color: var(--kui-color-hover);
      }

      &:active {
        background-color: var(--kui-color-active);
      }
    }

    .k-menu-submenu-sub {
      transition: all 0.3s cubic-bezier(.215, .61, .355, 1);
      overflow: hidden;
      position: static;
    }

    >.k-menu-submenu-opened>.k-menu-submenu-title>.k-menu-submenu-arrow {
      transform: translateY(-2px);

      &::before {
        transform: rotate(-45deg) translateX(-2.5px);
      }

      &::after {
        transform: rotate(45deg) translateX(2.5px);
      }
    }

    //light
    .k-menu-item-selected {
      background-color: var(--kui-color-selected);

      &::after {
        display: none;
      }
    }

  }

  &-vertical {
    width: 100%;
    border-right: 1px solid var(--kui-color-border);
    display: inline-block;

    .k-menu-item-selected {
      background-color: var(--kui-color-selected);
    }

    .k-menu-submenu-active,
    .k-menu-submenu-selected {
      .k-menu-submenu-title {
        color: var(--kui-color-main);
      }
    }

    >.k-menu-item,
    >.k-menu-submenu {
      line-height: 1;
      position: relative;
      cursor: pointer;
      font-size: 14px;
      z-index: 3;
      list-style: none;
    }

    .k-menu-item,
    .k-menu-submenu-title {
      padding: 10px 12px;
      margin: 4px;
      // height: 40px;
      box-sizing: border-box;
      line-height: 1;
      border-radius: var(--kui-border-radius);
      // display: flex;
      // align-items: center;

      &:hover {
        background-color: var(--kui-color-hover);
      }

      &:active {
        background-color: var(--kui-color-active);
      }
    }

    .k-menu-submenu-sub {
      position: absolute;
      top: 0;
      box-sizing: content-box;
      position: absolute;
      z-index: 1001;
      min-width: 160px;

      >.k-menu {
        border-radius: var(--kui-border-radius);
        border: none;
        margin: 0;
        list-style: none;

        .k-menu-item-group-title {
          line-height: 1;
          padding: 0 12px;
          box-sizing: border-box;
        }

        .k-menu-item-group-list .k-menu-item {
          position: relative;
        }

        .k-menu-item {
          line-height: 1;

          &:first-child {
            border-top-left-radius: var(--kui-border-radius);
            border-top-right-radius: var(--kui-border-radius);
          }

          &:last-child {
            border-bottom-left-radius: var(--kui-border-radius);
            border-bottom-right-radius: var(--kui-border-radius);
          }
        }
      }

      .k-menu-submenu {
        position: relative;
      }
    }

    >.k-menu-submenu>.k-menu-submenu-title>.k-menu-submenu-arrow {
      position: absolute;
      right: 16px;
      margin: 0;
      top: 50%;
      // transform: translateY(-50%);

      &::after,
      &::before {
        content: '';
        position: absolute;
        width: 6px;
        height: 1.5px;
        background-color: currentcolor;
        border-radius: 6px;
        transition: all .3s cubic-bezier(.215, .61, .355, 1);
      }

      &::before {
        transform: rotate(45deg) translateY(-2.5px);
      }

      &::after {
        transform: rotate(-45deg) translateY(2.5px);
      }
    }
  }

  &-horizontal {
    border-bottom: 1px solid var(--kui-color-border);
    white-space: nowrap;
    font-size: 0;
    line-height: 1;

    .k-menu-icon-temp {
      display: none;
    }

    >.k-menu-item,
    >.k-menu-submenu {
      line-height: 1;
      margin: 0 16px;
      position: relative;
      cursor: pointer;
      font-size: 14px;
      z-index: 3;
      display: inline-block;
      list-style: none;
      top: 1px;
      vertical-align: bottom;
      border-bottom: 2px solid transparent;
      display: inline-flex;
      align-items: center;
      min-height: 20px;
    }

    >.k-menu-item,
    >.k-menu-submenu-title {
      // margin: 0 16px;
      padding: 10px 0;
      box-sizing: border-box;
    }

    .k-menu-submenu-title {
      padding: 10px 0;
      box-sizing: border-box;
      // display: flex;
      // align-items: center;
    }

    .k-menu-submenu {

      .k-menu-item,
      .k-menu-submenu {
        display: block;
      }

      .k-menu-submenu {
        position: relative;

        .k-menu-submenu-sub {
          top: 0;
          margin-left: 5px;
        }
      }

      .k-menu-submenu-arrow {
        position: relative;
        // right: 16px;
        // top: 50%;
        // transform: translateY(-50%);

        &::after,
        &::before {
          content: '';
          position: absolute;
          width: 6px;
          height: 1.5px;
          background-color: currentcolor;
          border-radius: 6px;
          transition: all .3s cubic-bezier(.215, .61, .355, 1);
        }

        &::before {
          transform: rotate(45deg) translateX(-2.5px);
        }

        &::after {
          transform: rotate(-45deg) translateX(2.5px);
        }
      }
    }

    >.k-menu-submenu-active>.k-menu-submenu-title>.k-menu-submenu-arrow {
      // transform: rotate(-180deg);
    }

    .k-menu-item-group-title {
      font-size: 12px;
      line-height: 1;
      padding: 0 12px;
      box-sizing: border-box;
    }

    //light
    >.k-menu-item-selected,
    >.k-menu-submenu-selected,
    >.k-menu-item-active,
    >.k-menu-submenu-active {
      border-bottom-color: var(--kui-color-main);
      background-color: transparent;
    }

    .k-menu-submenu {
      .k-menu-item-selected {
        background-color: var(--kui-color-selected);
      }
    }
  }

  .k-menu-item-group-list {
    margin: 0;
  }
}


.k-menu-submenu-popup,
.k-dropdown-menu-submenu-popup {
  position: absolute;
  z-index: 1001;

  >.k-menu-submenu-sub {
    box-sizing: content-box;
    min-width: 160px;
    // margin-left: 5px;

    .k-menu-item-group-title {
      padding: 0 16px 0 12px;
      box-sizing: border-box;
    }

    .k-menu-item-group-list {
      margin: 0;
    }

    .k-menu {
      margin: 0;
      box-shadow: 0 1px 6px rgba(0, 0, 0, .2);
      border-radius: var(--kui-border-radius);
      background-color: var(--kui-color-control-10);
      border: 1px solid var(--kui-color-border);

      >.k-menu-item {
        line-height: 1;
        display: flex;
        align-items: center;

        &:first-child {
          border-top-left-radius: var(--kui-border-radius);
          border-top-right-radius: var(--kui-border-radius);
        }

        &:last-child {
          border-bottom-left-radius: var(--kui-border-radius);
          border-bottom-right-radius: var(--kui-border-radius);
        }
      }

      .k-menu-item-group {
        line-height: 1;

        &:last-child {
          .k-menu-item {
            &:last-child {
              border-bottom-left-radius: var(--kui-border-radius);
              border-bottom-right-radius: var(--kui-border-radius);
            }
          }
        }
      }
    }
  }

  .k-menu-submenu {
    position: relative;

    .k-menu-submenu-sub {
      // padding-left: 5px;
      left: calc(100% + 5px);
    }
  }

  .k-menu-vertical {
    border-right: none;

    .k-menu-icon-temp {
      display: none;
    }
  }
}


.k-menu-inline-collapsed {
  width: 80px;

  .k-menu-item,
  .k-menu-submenu-title {
    // overflow: visible;
    // display: block;
    padding-left: calc(50% - 12px);
    transition: padding 200ms 200ms ease-in-out;
    // padding-right: calc(50% - 12px);
  }

  .k-menu-submenu-selected {
    .k-menu-submenu-title {
      background-color: var(--kui-color-selected);
    }
  }

  >.k-menu-submenu {
    padding: 0;
  }

  .k-menu-item-icon {
    font-size: 16px;
    transition: all .3s ease-in-out;
    margin-right: 0;
  }

  .k-menu-submenu-arrow {
    opacity: 0;
  }


  .k-menu-title-content {
    opacity: 0;
    flex: auto;
    min-width: 0;
  }
}


@keyframes k-menu-zoom {
  0% {
    transform: scale(.8);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.k-menu-submenu-fade-enter-active,
.k-dropdown-menu-submenu-fade-enter-active {
  animation-fill-mode: both;
  transform-origin: 0% 0%;
  animation: k-menu-zoom 0.2s cubic-bezier(.215, .61, .355, 1);
}

.k-menu-submenu-fade-leave-active,
.k-dropdown-menu-submenu-fade-leave-active {
  animation-fill-mode: both;
  transform-origin: 0% 0%;
  animation: k-menu-zoom 0.2s cubic-bezier(.215, .61, .355, 1) reverse;
}

@keyframes drop-down {
  0% {
    opacity: 0;
    transform: scaleY(0)
  }

  to {
    opacity: 1;
    transform: scaleY(1)
  }
}


.k-dropdown-enter-active {
  animation: drop-down .3s;
}

.k-dropdown-leave-active {
  animation: drop-down .3s reverse;
}

.k-dropdown-menu-submenu-popup-enter-active,
.k-menu-submenu-popup-enter-active {

  &[k-placement="bottom-left"],
  &[k-placement="bottom-right"],
  &[k-placement="top-left"],
  &[k-placement="top-right"] {
    animation: drop-down .3s;
  }

  &[k-placement="left-bottom"],
  &[k-placement="right-top"],
  &[k-placement="left-top"],
  &[k-placement="right-bottom"] {
    animation-fill-mode: both;
    animation: k-menu-zoom 0.2s cubic-bezier(.215, .61, .355, 1);
  }
}

.k-dropdown-menu-submenu-popup-leave-active,
.k-menu-submenu-popup-leave-active {

  &[k-placement="left-bottom"],
  &[k-placement="right-top"],
  &[k-placement="left-top"],
  &[k-placement="right-bottom"] {
    animation-fill-mode: both;
    animation: k-menu-zoom 0.2s cubic-bezier(.215, .61, .355, 1) reverse;
  }

  &[k-placement="top-left"],
  &[k-placement="top-right"],
  &[k-placement="bottom-left"],
  &[k-placement="bottom-right"] {
    animation: drop-down .3s reverse;
  }
}

.k-collapse-slide-enter-active {
  animation: slide 0.15s ease-in-out;
  animation-fill-mode: both;
}

.k-collapse-slide-leave-active {
  animation: slide 0.3s ease-in-out reverse;
  animation-fill-mode: both;
}

@keyframes slide {
  0% {
    transform: scaleY(0);
    transform-origin: 0% 0%;
    opacity: 0;
  }

  100% {
    transform: scaleY(1);
    transform-origin: 0% 0%;
    opacity: 1;
  }
}